package logic

import (
	"context"
	"go.uber.org/zap"
	"homepage_srv/homepage"
	"homepage_srv/internal/dao"
	"homepage_srv/internal/svc"
	"smart-health-platforms/pkg"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodDetailSDKLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGoodDetailSDKLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodDetailSDKLogic {
	return &GoodDetailSDKLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 商品SDK详情
func (l *GoodDetailSDKLogic) GoodDetailSDK(in *homepage.GoodDetailSKURequest) (*homepage.GoodDetailSKUResponse, error) {
	goodSKU, err := dao.GoodDetailSKU(in)
	if err != nil {
		pkg.Error("商品SKU详情展示失败", zap.Error(err))
		return nil, err
	}
	pkg.Info("商品SDK详情列表查询成功")
	return &homepage.GoodDetailSKUResponse{
		List: goodSKU,
	}, nil
}
